import dark_web.log as log

bizArgs = {
    "openUrl": "http://deepmix5e3vptpr2.onion",
    #  "openUrl": "http://deepcnxpfgmausrq.onion",
    "args": {
        "input_username": "jiashiqi2019",  # 备用 0thegrass     zxc654321
        "input_password": "JiaShiQi2019",  # 备用 zaq1MKO0         Zxc654321
        "classIndex": "1"  #
    },
    "proxy": {
        # "proxyType": "HTTP",
        "proxyType": "SOCKS5",
        "proxyHeadersAccepted": "true",
        # "proxyAddress": "180.167.247.60:8008", #国内代理
        # "proxyAddress": "10.15.168.9:9051", #暗网代理
        # "proxyAddress": "10.15.168.9:8118", #暗网代理
        # "proxyAddress": "127.0.0.1:8889", #暗网代理
        # "proxyAddress": "127.0.0.1:8888", #暗网代理
        "proxyAddress": "11.239.237.115:9054",  # 暗网代理
        # "proxyAddress": "11.239.237.115:9053", #暗网代理
        "proxyAuth": ""
    },
    "renderId": "x-r",
    "queryId": "x-q"
}
log.info(bizArgs)
log.info(bizArgs['openUrl'])
log.info(bizArgs["proxy"])
log.info(bizArgs["proxy"]["proxyAddress"])
log.info("转变成json 对象之后 用.  进行访问")


class Dict2Obj(dict):
    def __init__(self, *args, **kwargs):
        super(Dict2Obj, self).__init__(*args, **kwargs)

    def __getattr__(self, key):
        value = self[key]
        if isinstance(value, dict):
            value = Dict2Obj(value)
        return value


jsonObj = Dict2Obj(bizArgs)
log.info(jsonObj)
log.info(jsonObj.openUrl)
log.info(jsonObj.proxy)
log.info(jsonObj.proxy.proxyAddress)


# logreport.delay(str(e))

class DarkNet_ChineseTradingNetwork(object):
    def __init__(self, bizArgs):
        self.result = ""  # 执行结果
        self.biz_args_dict = bizArgs  # dict字典暂存
        self.bizArgs = Dict2Obj(self.biz_args_dict)  # 实际转变成对象  方便和js 一样调用
        print(self.bizArgs.openUrl)


DarkNet_ChineseTradingNetwork(bizArgs)
